import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SealVO, SealForm, SealQuery, AdmSealAuditBo, DeptTreeNode } from '@/api/general/administration/seal/types';

/**
 * 查询公章管理列表
 * @param query
 * @returns {*}
 */

export const listSeal = (query?: SealQuery): AxiosPromise<SealVO[]> => {
  return request({
    url: '/adm/seal/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询公章管理详细
 * @param id
 */
export const getSeal = (id: string | number): AxiosPromise<SealVO> => {
  return request({
    url: '/adm/seal/' + id,
    method: 'get'
  });
};

/**
 * 新增公章管理
 * @param data
 */
export const addSeal = (data: SealForm) => {
  return request({
    url: '/adm/seal',
    method: 'post',
    data: data
  });
};

/**
 * 修改公章管理
 * @param data
 */
export const updateSeal = (data: SealForm) => {
  return request({
    url: '/adm/seal',
    method: 'put',
    data: data
  });
};

/**
 * 删除公章管理
 * @param id
 */
export const delSeal = (id: string | number | Array<string | number>) => {
  return request({
    url: '/adm/seal/' + id,
    method: 'delete'
  });
};

/**
 * 获取印章使用申请编号
 */
export const getSealNumber = (): AxiosPromise<string> => {
  return request({
    url: '/adm/seal/number',
    method: 'get'
  });
};

/**
 * 获取印章审核详情
 * @param id
 * @param auditType 审核类型：dept-部门审核，ceo-董办审核
 */
export const getAuditInfo = (id: string | number, auditType: string): AxiosPromise<SealVO> => {
  return request({
    url: '/adm/seal/audit/' + id,
    method: 'get',
    params: { auditType }
  });
};

/**
 * 审核公章申请
 */
export const auditSeal = (data: AdmSealAuditBo) => {
  return request({
    url: '/adm/seal/audit',
    method: 'post',
    data
  });
};

/**
 * 获取部门树
 */
export const getDeptTree = (): AxiosPromise<DeptTreeNode[]> => {
  return request({
    url: '/adm/seal/deptTree',
    method: 'get'
  });
};
